Restores switch state, case the switch is optimistic#14151
Merged
balloob merged 6 commits intohome-assistant:devfrom May 2, 2018
Merged
Restores switch state, case the switch is optimistic#14151balloob merged 6 commits intohome-assistant:devfrom
balloob merged 6 commits intohome-assistant:devfrom
Conversation
Contributor
Author
|
If this PR gets through I will gladly update the mqtt platforms in the light component. |
balloob
reviewed
May 1, 2018
| self.entity_id) | ||
| if last_state: | ||
| self._state = last_state.state | ||
| self.async_schedule_update_ha_state() |
Member
There was a problem hiding this comment.
No need to schedule an update. We write the entity to the state machine right after this method is done.
balloob
requested changes
May 1, 2018
Member
balloob
left a comment
There was a problem hiding this comment.
Ok to merge when a test is added.
houndci-bot
reviewed
May 2, 2018
|
|
||
| if self._optimistic: | ||
| last_state = await async_get_last_state(self.hass, | ||
| self.entity_id) |
There was a problem hiding this comment.
continuation line over-indented for visual indent
|
|
||
| @asyncio.coroutine | ||
| def async_setup_platform(hass, config, async_add_devices, discovery_info=None): | ||
| async def async_setup_platform(hass, config, async_add_devices, discovery_info=None): |
balloob
approved these changes
May 2, 2018
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
When the switch works in optimistic mode, HA is unaware of the current switch state and always defaults to False on restart.
This pull request restores the state of the switch to the last state, which is somehow what is expected from an optimistic switch (that he has kept the state since the last restart and not defaulted to False)
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests pass